<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="com.bean.User" %>

<html>
<head>
    <title>分享</title>

    <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/styles.css" rel="stylesheet">
    <link rel="shortcut icon" href="webicon.ico" type="image/x-icon" />

    <script src="js/jquery.min.js"></script>
    <script src="js/scripts.js"></script>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords" content="" />
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- kindeditor -->
    <link rel="stylesheet" href="kindeditor/themes/default/default.css"/>
    <link rel="stylesheet" href="kindeditor/themes/simple/simple.css"/>
    <script charset="utf-8" src="kindeditor/kindeditor-all-min.js"></script>
    <script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>
    <script type="text/javascript" charset="utf-8" src="kindeditor/splugins/code/prettify.js"></script>
    <script>
        KindEditor.ready(function(K) {
            var editor = K.create('textarea[name="share_content"]', {

                themeType : 'simple',
                height:'700px',
                resizeType : 1,
                allowPreviewEmoticons : false,
                cssPath:"css/kindeditorimage.css",
                allowImageUpload : true, //打开本地上传图片功能
                //formatUploadUrl: false,
                //urlType:'absolute',
                uploadJson :'<%=request.getContextPath()%>/kindeditor/jsp/upload_json.jsp',
                fileManagerJson : '<%=request.getContextPath()%>/kindeditor/jsp/file_manager_json.jsp',
                allowFileManager : true,
                items : [
                    'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
                    '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'quickformat', '|','/',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor','bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', '|', 'hr','image'],//编辑框功能

                //同步kindeditor的值到textarea
                afterCreate: function () {
                    this.sync();
                },
                afterBlur : function() {
                    this.sync();
                    K.ctrl(document, 13, function() {
                        K('form[name="myform"]')[0].submit();
                    });
                    K.ctrl(this.edit.doc, 13, function() {
                        K('form[name="myform"]')[0].submit();
                    });
                }
            });
            prettyPrint();
        });

    </script>

    <!-- hr中加文字 & 分享按钮 & table边距-->
    <style type="text/css" media="all">
        .hrLine{
            vertical-align:middle; display:inline-block;
        }
        .button{
            background-color:gray;
            border: none;
            color: white;
            padding: 15px 30px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 15px;
            margin: 6px 2px;
        }
        table td{padding:10px;}
    </style>
    <style type="text/css">
    
.selectStyle { width:100px; height:50px; background:none; border:none; }    
#sleHid { display:block; width:56px; overflow:hidden; }    
#sleBG  { width:78px; height:50px; border:#61AC36 1px solid; border-right:none;  background:url("../images/common/selArr.jpg") #fff no-repeat 62px 1px;  display:block;}
    
    </style>
    
</head>

<body>

<div class="navigation">
    <div class="container-fluid">
        <nav class="pull">
            <ul>
                <li><a  href="index.jsp">主页</a></li>
                <li><a  href="travelList.jsp?page=1">驴友游记</a></li>
                <li><a  href="share.jsp">发布游记</a></li>
            </ul>
        </nav>
    </div>
</div>

<div class="header">
    <div class="container">


        <div class="top-nav">
            <ul class="right-icons">

                <!--根据是否登录显示-->
                <li>
                    <% if(session.getAttribute("user") == null){ %>
                    <a  href="login.jsp">
                        <i class="glyphicon glyphicon-user">
                        </i>Login</a></li>
                <% } else {
                    //获取用户名name
                    int ID = ((User)(session.getAttribute("user"))).getUsername();
                    String name = ((User)(session.getAttribute("user"))).getName();%>
                <a  onclick="window.location.href='UserServlet?method=admin&ID=<%=ID%>'">
                    <i class="glyphicon glyphicon-user">
                    </i><%=name%></a></li>
                <% }
                %>

            </ul>

            <div class="nav-icon">
                <div class="hero fa-navicon fa-2x nav_slide_button" id="hero">
                    <a href="#"><i class="glyphicon glyphicon-menu-hamburger"></i> </a>
                </div>
            </div>

            <link href="css/popuo-box.css" rel="stylesheet" type="text/css" media="all"/>
            <script src="js/jquery.magnific-popup.js" type="text/javascript"></script>


            <script src="js/easyResponsiveTabs.js" type="text/javascript"></script>
            <script type="text/javascript">
                $(document).ready(function () {
                    $('#horizontalTab').easyResponsiveTabs({
                        type: 'default', //Types: default, vertical, accordion
                        width: 'auto', //auto or any width like 600px
                        fit: true   // 100% fit in a container
                    });
                });
            </script>
        </div>
    </div>
    <script>
        $(document).ready(function() {
            $('.popup-with-zoom-anim').magnificPopup({
                type: 'inline',
                fixedContentPos: false,
                fixedBgPos: true,
                overflowY: 'auto',
                closeBtnInside: true,
                preloader: false,
                midClick: true,
                removalDelay: 300,
                mainClass: 'my-mfp-zoom-in'
            });

        });
    </script>


</div>
<div class="clearfix"> </div>


<!--//header-->
<div class="blog"> 
    <div class="container">

        <div class="blog-top" class="container" align="center">
            <form action="UserServlet?method=share" method="post" class="contact-form" name="sharefrom" >
                <input type="hidden" name="method" value="share">

                <!--获取用户ID，如果未登录则无法上传-->
                <% if(session.getAttribute("user") != null){
                    int name = ((User)(session.getAttribute("user"))).getUsername();
                %>

                <input type="hidden" name="ID" value="<%=name%>">
                <%}else{%>
                <input type="hidden" name="ID" value="">
                <%}%>
                <table width="80%" border="0" cellpadding="10%" cellspacing="0">
                    <tr>
                        <td colspan="2">
                            <div style=" width:100%; text-align:left; margin-left:5%; margin-right:5%;">
                                <br><br><hr class="hrLine" style="width:40%;"/><font size="5">游记标题</font>  <hr class="hrLine" style="width:40%;"/>
                            </div>
                        </td >
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div class="form-group">
                                <input type="text" id="share_title" name="share_title" class="form-control"  required
                                       onkeyup="if(this.value.length>40)alert('标题不要超过40个字！');"
                                       onafterpaste="if(this.value.length>40)alert('标题不要超过40个字！');"/>
                            </div>
                        </td>
                    </tr>
                    <tr>
                         <td>
                            <div class="form-group">
                                <p>旅行地点：
                                <input type="text" id="share_city" name="share_city" class="form-control"required
                                /></p>
                                                 
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <p>旅行天数（天）：
                                <input type="text" id="share_days" name="share_days" class="form-control" required
                                                  onkeyup="if(this.value.length<=3&&this.value!=0){this.value=this.value.replace(/[^0-9]/g,'')}else{alert('请输入100以内的正整数！');this.value='';}"
                                                  onafterpaste="if(this.value.length<=3&&this.value!=0){this.value=this.value.replace(/[^0-9]/g,'')}else{alert('请输入100以内的正整数！');this.value='';}"/></p>
                            </div>
                        </td>
                        <td>
                            <div class="form-group">
                                <p>旅行花费（元）：
                                <input type="text" id="share_cost" name="share_cost" class="form-control" required
                                                  onkeyup="if(this.value.length<=6&&this.value!=0){this.value=this.value.replace(/[^0-9]/g,'')}else{alert('请输入100000以内的正整数！');this.value='';}"
                                                  onafterpaste="if(this.value.length<=6&&this.value!=0){this.value=this.value.replace(/[^0-9]/g,'')}else{alert('请输入100000以内的正整数！');this.value='';}"/></p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div style=" width:100%; text-align:left; margin-left:5%; margin-right:5%;">
                                <hr class="hrLine" style="width:40%;"/><font size="5">游记内容 </font> <hr class="hrLine" style="width:40%;"/>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div class="form-group">
                                <textarea id="share_content" name="share_content" class="form-control" rows="9" required></textarea>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div align="center"><button class="button" type="submit">分享</button></div>
                        </td>
                    </tr>
                    <tr>
                        <td >
                            <div align="center">
                                  <%  java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
                                      java.util.Date currentTime = new java.util.Date();//得到当前系统时间 
                                      String date = formatter.format(currentTime); //将日期时间格式化 
                                  %> 
                                <input type="hidden" id="share_time" name="share_time"
                                       value="<%=date%>">
                            </div>
                        </td>
                    </tr>
                </table>
            </form>
        </div>



        <div class="clearfix"> </div>

    </div>
</div>
<!--blog-->


</body>
</html>